<?php
include ('../../__global.php');

class search_user extends ml_controller {
    
    private $searchKey;
    private $searchWhere;
    private $page;
    private $block;
    private $aid;
    
    function initParam(){
        
        $this->searchKey = $this->input('searchKey', '', '');
        $this->searchWhere = $this->input('where', '', 'nick');
        $this->page = intval($this->input('page' , '' , 1));
        if (1 > $this->page )  $this->page = 1;
            
        $this->aid = $this->__visitor['uid'];
    }
    
    function checkParam(){
        
        $this->searchKey = Tool_antiXss::clean_danger_param(trim($this->searchKey));
    }
    
    function main(){
        
        //行为LOG
        $ext = array(
            'page' => $this->page,
            'where' => $this->searchWhere,
        );
        ml_tool_actionlog::view_search($this->__visitor['uid'] , 'user' , $this->searchKey , $ext);
        
        $oSearch = new ml_biz_search_user($this->searchKey, $this->aid, $this->page);
        $oSearch->setSearchWhere($this->searchWhere);
        $aHtml = $oSearch->getSearchResult();
                                                                                                                                                                                                 
        $this->searchKey = Tool_string::un_html($this->searchKey);
        
        $total_page = $oSearch->get_total_block();
        $total_number = $oSearch->get_total_number();

        $data['searchKey'] = $this->searchKey;
        $data['total_number'] = $total_number;
        $data['userList'] = $aHtml;
        $data['searchWhere'] = $this->searchWhere;
        

        $this->set_scope_var('$totalPage' , ceil($total_page));
        $this->set_scope_var('$currentPage' , $this->page);
        $this->set_scope_var('$searchKey' , $this->searchKey);    
            
        $title = $data['searchKey']. ' - 用户搜索';
        $this->set_page_title($title);
        
        $this->page_output('search::search_user', $data);
    }
    
}

new search_user();